<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/views/include/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="/skyline/css/comment.css" rel="stylesheet" type="text/css" />
<link href="/skyline/css/base.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="${pageContext.request.contextPath}/js/stringutil.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/base.js"></script>

<script type="text/javascript">
function Notice(){
	this.getNotificationsUrl="/skyline/notice/list.html";
	this.getNotifications=function(){
		var url=this.getNotificationsUrl;
		var data=null;
		$.ajax({
			url: url,
			data:data,
			type : "GET",
			dataType:"json",
			contentType: "application/x-www-form-urlencoded; charset=utf-8", 
			success : function(msg){
				//alert(msg);
				var notificationsDiv=document.getElementById("notifications");
				notificationsDiv.innerHTML+="共"+msg.length+"条通知:<br>";
				for(var i=0;i<msg.length;i++){
					var notification=msg[i];
					notificationsDiv.innerHTML+=notice.getNotification(notification)+"<br>";
				}
			}
		});
	}
	this.getNotification=function(notification){
		var notiStr="";
		notiStr+="<a href='"+notification.notifierId+"'>"+notification.notifierNickname+"</a>";
		if(notification.secondNotifierId&&notification.secondNotifierId!=''){
			notiStr+="与<a href='"+notification.secondNotifierId+"'>"+notification.secondNotifierNickname+"</a>等";
		}
		if(notification.type=='ARTICLE_COMMENT'){
			notiStr+="在您的日志<a href='"+SKYLINE_VIEWNOTIFICATION+notification.id+".html'>"+notification.resourceTitle+"</a>回复了您。";
		}else	if(notification.type=='PHOTO_COMMENT'){
			notiStr+="在您的照片<a href='"+SKYLINE_VIEWNOTIFICATION+notification.id+".html'>"+notification.resourceTitle+"</a>回复了您。";
		}else if(notification.type=='ALBUM_COMMENT'){
			notiStr+="在您的相册<a href='"+SKYLINE_VIEWNOTIFICATION+notification.id+".html'>"+notification.resourceTitle+"</a>回复了您。";
		}else if(notification.type=='FOLLOW'){
			notiStr+="观注您。";
		}
		return notiStr;
	}
}
var notice=new Notice();
//notice.getNotifications();
window.load=notice.getNotifications();
</script>
</head>
<body>
<%@ include file="/views/include/statusbar.jsp"%>

<div id="notifications">
</div>
</body>
</html>